package br.com.tcc;

import java.sql.Connection;
import java.util.ArrayList;

public class ServicoA {

	private static Connection conexao;
	public ServicoA() {
		
		conexao = Conexao.getConexao();
		
	}

	
	public ArrayList<String> buscarApolice(String cpf, String placa, String cor){
		ServicoADao dao = new ServicoADao();
		
		return  dao.buscarApolice(cpf, placa, cor);
	}
		
	
	
	public ArrayList<String> inserirSinistro(SinistroWrapperWS wrapper, ArrayList<String> partes){
		
		ServicoADao dao = new ServicoADao();
		
		return dao.inserirSinistro(wrapper, partes);
		
	}
	
	public ArrayList<String> buscarStatusSinistro(int idSinistro){
		
		ServicoADao dao = new ServicoADao();
		
		return dao.buscarStatusSinistro(idSinistro);
		
	}
	
	
	/*	public Wrapper getApolice(String cpf, String placa, String cor) {

	Wrapper w = null;
	try {
		
		
		String sql = "SELECT A.ID_APOLICE_PK, A.NUM_APOLICE, A.DT_VENCIMENTO_APOLICE, A.ID_PLANO_FK, " +
				     "S.NOME_COMPLETO, V.MODELO,V.PLACA,V.COR " +
				     "FROM TAB_APOLICE A, TAB_SEGURADO S, TAB_VEICULO V " +
				     "WHERE A.ID_SEGURADO_FK = S.ID_SEGURADO_PK " +
				     "AND A.ID_VEICULO_FK = V.ID_VEICULO_PK " +
				     "AND S.CPF_SEGURADO = ? " +
				     "AND V.PLACA = ?";
		
	
		
		

		PreparedStatement ps = conexao.prepareStatement(sql);
		ps.setString(1, cpf);
		ps.setString(2, placa.toUpperCase());

		ResultSet rs = ps.executeQuery();

		while (rs.next()) {

			 w = new Wrapper();
			
			w.setIdApolice(Integer.parseInt(rs.getString("ID_APOLICE_PK")));
			w.setNumeroApolice(rs.getString("NUM_APOLICE"));
			
			Calendar c = Calendar.getInstance();
			c.setTime(rs.getDate("DT_VENCIMENTO_APOLICE"));
			
			w.setVencimento(c);
		
			w.setIdPlano(Integer.parseInt(rs.getString("ID_PLANO_FK")));
			

			w.setNome(rs.getString("NOME_COMPLETO"));
			
			w.setModelo(rs.getString("MODELO"));
			w.setPlaca(rs.getString("PLACA"));
			w.setCor(rs.getString("COR"));
			break;

		}

		ps.close();
		rs.close();
	} catch (SQLException ex) {
		ex.printStackTrace();
		System.exit(1);
	} finally {

		if (conexao != null) {
			try {
				conexao.close();
			} catch (SQLException e) {

			}

		}

	}
		
		return w;
	
}
*/


/*	public boolean inserirSinistro(Wrapper wrapper){
	
	ServicoADao dao = new ServicoADao();
	
	return dao.inserirSinistro(wrapper);
	
}*/
	
	
}
